package com.oa.service.impl;

import com.oa.mapper.PartyMapper;
import com.oa.pojo.Clock;
import com.oa.pojo.Party;
import com.oa.service.ClockService;
import com.oa.mapper.ClockMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
* @author 14541
* @description 针对表【clock】的数据库操作Service实现
* @createDate 2023-11-03 15:31:37
*/
@Service
public class ClockServiceImpl implements ClockService{
    @Autowired
    private ClockMapper clockMapper;
    @Override
    public List<Clock> select(Clock clock){
        return clockMapper.select(clock);
    }
    @Override
    public int insert(Clock clock){
        int clockvalue=0;
        Clock clock1=new Clock();
        clock1.setId(clock.getId());
        List<Clock> getP=clockMapper.select(clock1);
        if(getP.size()>=1){
            clockvalue=-1;
        }else{
            clockvalue=clockMapper.insert(clock);
        }
        return clockvalue;
    }

    @Override
    public int update(Clock clock) {
        int clockvalue=0;
        Clock clock1=new Clock();
        clock1.setId(clock.getId());
        List<Clock> clockList=new ArrayList<>();
        clockList=select(clock1);
        if(clockList.size()>=1){
            clockvalue=clockMapper.update(clock);
        }else{
            clockvalue=-1;
        }
        return clockvalue;
    }
    @Override
    public int delete(Clock clock){
        int clockvalue=0;
        Clock clock1=new Clock();
        clock1.setId(clock.getId());
        List<Clock> clockList=new ArrayList<>();
        clockList=select(clock1);
        if(clockList.size()>=1){
            clockvalue=clockMapper.delete(clock);
        }else{
            clockvalue=-1;
        }
        return clockvalue;
    }
}




